package com.rock.securityresearch.db
import com.rock.securityresearch.entity.Stock
import scalikejdbc.*

object Db {
    Class.forName("org.postgresql.Driver")
    ConnectionPool.singleton("jdbc:postgresql://localhost:5432/SecurityResearch", "postgres", "123456")
    // ad-hoc session provider on the REPL
    given AutoSession = AutoSession

    def findStocks() = {
        val stocks: List[Stock] = sql"select * from stock".map(rs => Stock(rs)).list.apply()
        stocks
    }
}
